package util

import org.apache.spark.sql.expressions.UserDefinedFunction
import org.apache.spark.sql.functions.udf

/**
  * Created by 6v on 2018/11/6.
  */
object RoiUdfUtil {

  /**
    * 根据userid获取userType
    */
  val getUserTypeFromUserId: UserDefinedFunction = udf((userid: String) => {
    if ("-" == userid) 2 else 1
  })


  /**
    * 获取操作平台
    IOS  4 //IOS
    ANDROID = 5 //ANDROID
    */
  val getPlatform: UserDefinedFunction = udf((ua: String) => {
    if (ua.contains("iOS")) 5 else 4
  })


  /**
    * 职位来源
      58 1 赶集 2
    */
  val getInfoApp: UserDefinedFunction = udf((infoid: String) => {
    if (infoid.length>12) 1 else 2
  })
}
